package com.why.mapper;

import com.why.pojo.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

/**
* @author 王-自信
* @description 针对表【user(用户表)】的数据库操作Mapper
* @createDate 2024-11-26 16:12:56
* @Entity com.why.pojo.User
*/
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where username=#{username}")
    User findByUserName(String username);

    @Insert("insert into user(username,password,create_time,update_time) " +
            "values (#{username},#{password},#{createTime},#{updateTime})")
    void add(User user);

    void update(User user);

    @Update("update user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
    void updateAvatar(String avatarUrl,Integer id);

    @Update("update user set password=#{newPwd},update_time=now() where id=#{id}")
    void updatePwd(String newPwd, Integer id);
}




